home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / tweak16b.zip / NAMEDREG.CPP < prev    next >
C/C++ Source or Header  |  1993-08-04  |  1KB  |  53 lines

  1. /*
  2.     NamedReg.CPP version 1.0
  3.     by Robert Schmidt of Ztiff Zox Softwear 1993
  4.  
  5.     Defines the member functions of the NamedRegister class declared in
  6.         Register.hpp.
  7.     Defines the stream operator >> to read named register info from
  8.         an istream.  (Text mode)
  9. */
  10.  
  11. #include <conio.h>
  12. #include <iostream.h>
  13. #include <string.h>
  14. #include "Screen.hpp"
  15. #include "Register.hpp"
  16.  
  17.  
  18. // NamedRegister::printCon() prints the register state to the console.
  19. //    If enableFlag is zero, the value is omitted from the display, and
  20. //    its place is filled with spaces.
  21.  
  22. void NamedRegister::printCon()
  23.     {
  24.     textattr(enableFlag?REGENABLE_COLOR:REGDISABLE_COLOR);
  25.     cprintf("%03hx (%02hx) %24s : %02hx", getPort(), getIndex(),
  26.         name, getValue());
  27.     }
  28.  
  29. /*
  30.     This operator reads the register port number, index and name from the
  31.     input stream.  (*Not* the value!)  Used for initializing each element
  32.     in the register table used by TWEAK.
  33. */
  34.  
  35. istream& operator>> (istream &in, NamedRegister &r)
  36.     {
  37.     int i;
  38.     char *n = new char[128];
  39.  
  40.     in >> hex >> i;
  41.     r.setPort(i);
  42.     in >> i >> ws;
  43.     r.setIndex((unsigned char)(i));
  44.     in.getline(n, 128);
  45.     n[in.gcount()-1] = '\0';
  46.     r.name = new char[strlen(n)+1];
  47.     strcpy(r.name, n);
  48.     delete[] n;
  49.  
  50.     return in;
  51.     }
  52.  
  53.